use "$temp/acs_longform_merged_clean", clear
keep if dby>=1990 //restrict to at-risk sample

cap drop age_group
gen age_group = 0
replace age_group = 1 if age>=17 & age<=19
replace age_group = 2 if age>=20 & age<=22
replace age_group = 3 if age>=23 & age<=25
replace age_group = 4 if age>=26 & age<=28

//final cleaning
replace coll = 0 if age_group == 1
replace assoc = 0 if age_group == 0
drop if parent_inc_quart == .  //nix matched kids with no parent income

//restrict to middle quartiles
keep if parent_inc_quart == 2 | parent_inc_quart == 3
tab own_house 
tab head_constr_manu

***********************college**********************
//base
local controls `"cz_shock sex asian black hispan i.year i.state_2000#i.head_coll i.age_group head_mar head_constr_manu house_value parent_inc own_house"'
reg coll c.cz_shock#i.age_group `controls' [aw = weight], vce(cluster cz_2000)
outreg2 using "$temp/07_middlequart_het.dta", dta replace keep(c.cz_shock#i.age_group) noast dec(3)

*****interaction with housing dummy
local controls `"cz_shock sex asian black hispan i.year i.state_2000#i.head_coll i.age_group head_mar head_constr_manu house_value parent_inc own_house"'

//with housing
reg coll c.cz_shock#i.age_group `controls' [aw = weight] if own_house, vce(cluster cz_2000)
outreg2 using "$temp/07_middlequart_het.dta", dta keep(c.cz_shock#i.age_group) noast dec(3)

//without
reg coll c.cz_shock#i.age_group `controls' [aw = weight] if !own_house, vce(cluster cz_2000)
outreg2 using "$temp/07_middlequart_het.dta", dta keep(c.cz_shock#i.age_group) noast dec(3)

*****interaction with dummy for head working in construction or manufacturing
local controls `"cz_shock sex asian black hispan i.year i.state_2000#i.head_coll i.age_group"'

//in manufacturing/construction 
reg coll c.cz_shock#i.age_group `controls' [aw = weight] if head_constr_manu, vce(cluster cz_2000)
outreg2 using "$temp/07_middlequart_het.dta", dta keep(c.cz_shock#i.age_group) noast dec(3)

//not
reg coll c.cz_shock#i.age_group `controls' [aw = weight] if !head_constr_manu, vce(cluster cz_2000)
outreg2 using "$temp/07_middlequart_het.dta", dta keep(c.cz_shock#i.age_group) noast dec(3)

****re-export as regression table
use "$temp/07_middlequart_het_dta.dta", clear
drop if _n == 12 | _n == 13
set obs 16
replace v1 = "Sample" in 15
replace v2 = "Base" in 15
replace v3 = "Has House Equity" in 15
replace v4 = "No House Equity" in 15
replace v5 = "Head in C/M" in 15
replace v6 = "Head not in C/M" in 15
replace v1 = "Standard errors clustered at CZ level" in 16
export excel using "$output/for_disclosure/output/effects_middlequart_het.xls", replace
